import Vue from 'vue'
import VueRouter from 'vue-router'

import Layout from '@/layout' //布局页

Vue.use(VueRouter)

// 通用页面, 这里的配置不需要权限
export const constRouter = [
  {
      path: '/login',
      component: () => import('@/views/login'),
      hidden: true //导航菜单忽略选项
  },
  {
      path: '',
      component: Layout, //应用布局页
      redirect: '/index',
      hidden: true,
  },
  {
      path: '/index',
      component: Layout, //应用布局页
      name: 'index',
      meta:{
          title: "首页", //导航菜单项标题
          icon: 'el-icon-s-home' //导航菜单图标
      },
      children: [
        {
          path: '',
          component: () => import('@/views/index/index.vue'),
          name: 'indexs',
          meta: {
            title: "工作台",
            icon: 'el-icon-s-home',
            roles: ['admin','jerry']
          }
        }
      ]
  }
]

// 动态路由 communication
export const asyncRoutes = [
  {
    path: '/analyze',
    component: Layout,
    redirect: '/goods/index',
    meta: {
      title: "数据分析",
      icon: 'el-icon-s-marketing',
      hidden: false
    },
    children: [
      {
        path: 'analyzeindex',
        component: () => import('@/views/analyze/Index.vue'),
        name: 'analyzeindex',
        meta: {
          title: "主控数据",
          icon: 'el-icon-tickets',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'analyzemonitor',
        component: () => import('@/views/analyze/Monitor.vue'),
        name: 'analyzemonitor',
        meta: {
          title: "监控数据",
          icon: 'el-icon-tickets',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
    ]
  },
  {
    path: '/system',
    component: Layout,
    redirect: '/system/user/index',
    meta:{
      title: "系统管理",
      icon: 'el-icon-s-tools',
      hidden: false,
    },
    children: [
      {
        path: 'sysUser',
        component: () => import('@/views/system/user/index.vue'),
        name: 'userindex',
        meta: {
          title: "用户管理",
          icon: 'iconfont icon-yonghu',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'sysRole',
        component: () => import('@/views/system/role/index.vue'),
        name: 'roleindex',
        meta: {
          title: "角色管理",
          icon: 'iconfont icon-jiaoseguanli',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'sysMenu',
        component: () => import('@/views/system/menu/index.vue'),
        name: 'menuindex',
        meta: {
          title: "菜单管理",
          icon: 'iconfont icon-caidanguanli',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'sysDict',
        component: () => import('@/views/system/dict/index.vue'),
        name: 'dictindex',
        meta: {
          title: "字典管理",
          icon: 'iconfont icon-zidian',
          hidden: false,
          roles: ['admin','jerry']
        }
      },
      {
        path: 'sysOrder',
        component: () => import('@/views/system/order/index.vue'),
        name: 'orderindex',
        meta: {
          title: "订单管理",
          icon: 'el-icon-c-scale-to-original',
          hidden: false,
          roles: ['admin','jerry']
        }
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: constRouter
})

export default router

